<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var a = [1, 2, 3, 4, 5, 2, 3, 5, 5, 5, 5];
      // 排序
      a.sort((a, b) => {
        return a - b;
      });
      function info(arr) {
        let a = [];
        for (var i in arr) {
          if (a.indexOf(arr[i]) == -1) {
            a.push(arr[i]);
          }
        }
        return a;
      }
      let list = info(a);
      console.log(list); // 输出结果 [1, 2, 3, 4, 5]

      function unqueIn(arr) {
        let newArray = [];
        for (let i = 0; i < arr.length; i++) {
          if (newArray.indexOf(arr[i]) === -1) {
            newArray.push(arr[i]);
          }
        }
        return newArray;
      }
      // ES6去重
      function unique(arr) {
        return Array.from(new Set(arr));
      }
      console.log(unique(a));
    </script>
  </body>
</html>
